<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报关单登记系统</title>
<!--#include file="lib/js-jquery-lib.asp"-->
<script type="text/javascript" src="lib/jquery.printElement.min.js"></script>
<!--#include file="lib/js-jquery-barcode-lib.asp"-->
<script type="text/javascript">
  $(function() {
  
    $("#bcTarget").barcode($("#cd_no").html(), "code128",{barWidth:2, barHeight:30,showHRI:false});
  /*
    // set portrait orientation
    //jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);
    jsPrintSetup.setOption('orientation', jsPrintSetup.kLandscapeOrientation);
    // set top margins in millimeters
    jsPrintSetup.setOption('marginTop', 15);
    jsPrintSetup.setOption('marginBottom', 15);
    jsPrintSetup.setOption('marginLeft', 10);
    jsPrintSetup.setOption('marginRight', 10);
    // set page header
    jsPrintSetup.setOption('headerStrLeft', '');
    jsPrintSetup.setOption('headerStrCenter', '');
    jsPrintSetup.setOption('headerStrRight', '');
    // set empty page footer
    jsPrintSetup.setOption('footerStrLeft', '');
    jsPrintSetup.setOption('footerStrCenter', '&PT');
    jsPrintSetup.setOption('footerStrRight', '');
    jsPrintSetup.setOption('shrinkToFit', 1);
    jsPrintSetup.setOption('paperData','DMPAPER_A4');
    // clears user preferences always silent print value
    // to enable using 'printSilent' option
    jsPrintSetup.clearSilentPrint();
    // Suppress print dialog (for this context only)
    jsPrintSetup.setOption('printSilent', 1);
    // Do Print 
    // When print is submitted it is executed asynchronous and
    // script flow continues after print independently of completetion of print process! 
    //jsPrintSetup.print();
    // next commands

  */
  
    $('body').printElement();
  });
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%

id=trim(SafeRequest("id",1))
call SimpleRecord("cd",id,"打印","成功",session("iId"),session("iClientId"),false)
if id<>"" then
  sql = "select * from cdfee where id="&id
  ' if cdlastid<>"" then sql = "select * from cdfee where id="&cdlastid
  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open sql,conn,1,1
  if not rs.eof then
    wtr_name=rs("wtr_name")
    category_name=rs("category_name")
    cd_no=rs("cd_no")
    cd_date=rs("cd_date")
    cd_company=rs("cd_company")
    cd_voyage=rs("cd_voyage")
    cd_lading=rs("cd_lading")
    cd_verify=rs("cd_verify")
    cd_status=rs("cd_status")
    cd_statusdate=rs("cd_statusdate")
    cd_receive=rs("cd_receive")
    cd_pay=rs("cd_pay")
    cd_post=rs("cd_post")
    username=rs("username")
    cd_update=rs("cd_update")
    cd_passno=rs("cd_passno")
    cd_orderno=rs("cd_orderno")
    cd_boxno=rs("cd_boxno")
    cd_memo=rs("cd_memo")
    total_receive=rs("total_receive")
    total_pay=rs("total_pay")
    cd_actreceive=rs("cd_actreceive")
    cd_actpay=rs("cd_actpay")
    cd_received=rs("cd_received")
    cd_paid=rs("cd_paid")
  else
    response.write("未找到数据")
    response.end
  end if
  rs.close
  set rs=nothing
end if
%>
<body style="font-size:10pt;font-family:宋体;margin:0;padding:0">
<div style="position: absolute;right:-10pt;bottom:-0"><img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=单号:<%=cd_no%>+单位:<%=wtr_name%>+航次:<%=cd_voyage%>+提号:<%=cd_lading%>+销号:<%=cd_verify%>+箱号:<%=cd_boxno%>+报关费:<%=cd_receive%>+合计:<%=total_receive%>+备注:<%=cd_memo%>+URL:<%
        oldurl="http://"&request.ServerVariables("HTTP_HOST")&request.ServerVariables("Url")
        if request.ServerVariables("QUERY_STRING")<>"" then oldurl=oldurl&"?"&request.ServerVariables("QUERY_STRING")
        response.write oldurl
      %>" /></div>
<div>
<table id="cd" width="100%">
  <thead>
    <tr>
      <th colspan=4><h1><%=category_name%>费用明细单</h1></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;font-weight:bold;" width="10%">委托单位</td>
      <td width="40%"><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=wtr_name%>&nbsp;</div></td>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;padding-left:10pt;" width="10%"></td>
      <td width="40%"><div id="bcTarget"></div></td>
    </tr>
    <tr>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;font-weight:bold;">船名航次</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_voyage%>&nbsp;</div></td>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;padding-left:10pt;font-weight:bold;">报关单号</td>
      <td><div id="cd_no" style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_no%></div></td>
    </tr>
    <tr>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;font-weight:bold;">提单号</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_lading%>&nbsp;</div></td>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;padding-left:10pt;font-weight:bold;">核销单号</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_verify%>&nbsp;</div></td>
    </tr>
    <tr>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;font-weight:bold;">箱数(TEU)</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_boxno%>&nbsp;</div></td>
      <td style="width:70pt;line-height:20pt;padding-right:10pt;padding-left:10pt;font-weight:bold;">报关费</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;"><%=cd_receive%>&nbsp;</div></td>
    </tr>
    <tr>
      <td colspan="4">
        <%
          Set rs_calc = Server.CreateObject("ADODB.Recordset")
          sql = "SELECT * FROM catecount"
          rs_calc.Open sql,conn,1,1
          aaCate=rs_calc.getrows
          iCate=ubound(aaCate,1)
          rs_calc.close
          sql="select max(num) as row from(select count(feecategory) as num from detail group by feecategory)"
          rs_calc.Open sql,conn,1,1
          iRow=rs_calc("row")
          rs_calc.close
          'sql="select detail.id as detailid,detail.feecategory as cateid,detail.feename as detailname,detail.short as detailshort,iif(isnull(receive),0,receive) as detailreceive,iif(isnull(pay),0,pay) as detailpay,f.id as feeid from (SELECT * FROM fee where cd="
          sql="select detail.id as detailid,detail.feecategory as cateid,detail.feename as detailname,detail.short as detailshort,receive as detailreceive,pay as detailpay from (SELECT * FROM fee where cd="
          if id<>"" then
            sql=sql&id
          ' elseif cdlastid<>"" then
            ' sql=sql&cdlastid
          else
            sql=sql&"0"
          end if
          sql=sql&") as f right join detail on f.detail=detail.id order by detail.feecategory asc,detail.id asc"
          
          rs_calc.Open sql,conn,1,1
          aaFee=rs_calc.getrows
          rs_calc.close
          set rs_calc=nothing

        %>
        <table id="fee" width="100%">
          <thead>
            <tr>
            <%
              for i=0 to iCate
            %>
              <th colspan="2"><h3><%=aaCate(1,i)%></h3></th>
            <%
              next
            %>
            </tr>
          </thead>
          <tbody>
          <%
            for i=0 to iRow-1
          %>
            <tr>
            <%
              for j=0 to iCate
            %>
              <td width="12.5%" style="width:70pt;line-height:18pt;padding-right:10pt;<%if j<>0 then response.write("padding-left:10pt;")%>">
              <%
                'aaCate(0,j)=1 aaCate(3,j)=5
                if i\aaCate(3,j)>=1 then
                  response.write("")
                else
                  'aaFee(2,0)=码头费用
                  n=0
                  for z=0 to j-1
                    n=n+aaCate(3,z)
                  next
                  n=n+i
                  response.write(aaFee(2,n))
                end if
              %>
              </td>
              
              <%
                'aaCate(0,j)=1 aaCate(3,j)=5
                if i\aaCate(3,j)>=1 then
                  response.write("<td></td>")
                else
                  'aaFee(2,0)=码头费用
                  n=0
                  for z=0 to j-1
                    n=n+aaCate(3,z)
                  next
                  n=n+i
                  if aaFee(4,n)=0 then aaFee4r="<td></td>" else aaFee4r="<td width='12.5%'><div style='border-bottom: 1px black solid;padding:0 10pt;'>"&aaFee(4,n)&"&nbsp;</div></td>"
                  response.write(aaFee4r)
                end if
              %>
              
            <%
              next
            %>
            </tr>
          <%
            next
          %>

          </tbody>
        </table>
      </td>
    </tr>
    <tr>
      <td colspan="4" height="30pt"></td>
    </tr>
  </table>
  <table width="100%">
    <tr>
      <td rowspan="2" valign="top" width="50%"><em>备注：<%=cd_memo%></em></td>
      <td style="width:70pt;line-height:30pt;padding-right:10pt;padding-left:10pt;font-size:large;font-weight:bold;">合计</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;font-size:large;font-weight:bold;"><%=total_receive%>&nbsp;</div></td>
      <td width="10%"></td>
    </tr>
    <tr>
      <td style="width:70pt;height:50pt;line-height:20pt;padding-right:10pt;padding-left:10pt;font-size:large;font-weight:bold;">费用确认</td>
      <td><div style="border-bottom: 1px black solid;padding:0 10pt;">&nbsp;</div></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
</body>
</html>
<!--#include file="lib/connclose.asp"-->

